package com.aaa.docter.controller.api;

import com.aaa.docter.service.RegistrationService;
import com.aaa.docter.vo.DeptVo;
import com.aaa.docter.vo.RegistrationVo;
import com.aaa.entity.Dept;
import com.aaa.entity.HisRegistration;
import com.aaa.entity.Scheduling;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/doctor/patient/api")
public class ApiRegistrationController {



    @Autowired
    private RegistrationService registrationService;

//    挂号列表
    @PostMapping("getAllRegist/{currentPage}/{pageSize}")
    public Result<IPage<HisRegistration>>getAll(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody RegistrationVo registrationVo
    ){
        return registrationService.getAll(currentPage,pageSize,registrationVo);
    }



//    查询收费是否成功，并更改status状态为‘0’，0代表未收费
//    http://localhost:8871/doctor/patient/api/getRegId/GH59820403220447232
    @GetMapping("/getRegId/{registrationId}")
    public Result getRegId(@PathVariable String registrationId){
        return registrationService.getRegId(registrationId);
    }




//    门诊+病历本---      门诊挂号，科室id/科室名称
//    http://localhost:8871/doctor/patient/api/getGuaHao/
    @PostMapping("/getGuaHao")
    public Result<List<Scheduling>> getGuaHao(@RequestBody DeptVo deptVo){
        return registrationService.getGuaHao(deptVo);
    }



//    退号,修改状态为4，变退号  --挂号列表页面
    @GetMapping("getregistrationId/{registrationId}")
    public Result<String>getregid(@PathVariable String registrationId){
        return registrationService.getTui(registrationId);
    }



//收费，修改状态为1，变待就诊  --挂号列表页面，
//    http://localhost:8871/doctor/patient/api/getshoufei/GH59820403220447232
    @GetMapping("getshoufei/{registrationId}")
    public Result<String>shoufei(@PathVariable String registrationId){
    return registrationService.getShoufei(registrationId);
    }



    //作废 修改状态为5，变作废  --挂号列表页面，
    @GetMapping("getzuofei/{registrationId}")
    public Result<String>zuofei(@PathVariable String registrationId){
        return registrationService.getzuofei(registrationId);
    }



//    接诊，载入患者信息  --就诊页面
//    通过 registrationId：GH57715016316956672 查询 患者信息
//    http://localhost:8871/doctor/patient/api/jiezhen/GH57715016316956672
    @PostMapping("jiezhen/{registrationId}")
    public Result<String>jiezhen(@PathVariable String registrationId){
        return registrationService.jiezhen(registrationId);
    }



    //    就诊完成
    @GetMapping("/queryVisitCompletedRegistration/{schedulingType}")
    public Result<List<HisRegistration>> queryVisitCompletedRegistration(@PathVariable String schedulingType){
        System.out.println("schedulingType111111111111111111111111111111111111 = " + schedulingType);
        return registrationService.queryVisitCompletedRegistration(schedulingType);
    }



    //获取挂号编号      获取门诊挂号中 根据部门编号获取当前号数
    @PostMapping("queryDeptNumber/{deptId}")
    public Result queryDeptNumber(@PathVariable Long deptId){
        Integer regNumber = registrationService.getRagNumber(deptId);
        return new Result(2000,"查询符合条件的挂号单成功",regNumber);
    }

}
